package edu.wust;

public class exam30 {
    public static boolean yn(int num){
        int temp=num,sum=0;
        while(temp!=0){
            int t=temp%10;
            sum+=t*t*t*t*t;
            temp/=10;
        }
        if(sum==num)
            return true;
        return false;
    }
    public static void main(String[] args) {
        int sum=0;
        for(int i=2;i<=1000000;i++){
            if(yn(i)){
                sum+=i;
                if(sum==443839)
                    break;
            }
        }
        System.out.println(sum);
    }
}

